//
//  PushURL.m
//  HYHoney
//
//  Created by dllo on 16/1/25.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "PushOfURL.h"
#import "SecondOfModel.h"
#import "RESideMenu.h"
#import "DKNightVersion.h"

@interface PushOfURL ()<UIWebViewDelegate>

@property (nonatomic, retain)NSMutableArray *arr;
@property (nonatomic, retain)UITableView *tableView;
@property (nonatomic, retain)UIWebView *web;
@property (nonatomic, retain)SecondOfModel *model;

@end

@implementation PushOfURL

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
}


- (void)dealloc{

    [_arr release];
    [_web release];
    [_tableView release];
    [_str release];
    [super dealloc];
}

- (void)passSecondModel:(SecondOfModel *)model{
    
    self.model = model;
    self.str = model.title;
    
    CGRect frame = self.view.frame;
    self.web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(frame), CGRectGetHeight(frame))];
    self.web.userInteractionEnabled = YES;
    self.web.delegate = self;
    self.web.opaque = NO;
    
    self.web.scrollView.contentInset = UIEdgeInsetsMake(0, 0, -80, 0);
    
    [self.view addSubview:self.web];
    NSURL *url = [NSURL URLWithString:model.shareUrl];
    [self.web loadRequest:[NSURLRequest requestWithURL:url]];
}



- (void)webViewDidFinishLoad:(UIWebView *)webView {
    
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"ISNIGHT"]) {
        [self.web stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='#27408B'"];
        
        [self.web stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor='#000000'"];
        
    }else {
        [self.web stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='#ffffff'"];
        
        [self.web stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor='#000000'"];
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
